﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Things.Bar.Models;

namespace Things.Bar
{
    public class NoticeTypeRepository
    {
        public bool Restore(NoticeType type)
        {
            using (Models.BarContainer container = new BarContainer())
            {
                container.NoticeTypeSet.AddObject(type);
                if (container.SaveChanges() > 0)
                {
                    return true;
                }
            }
            return false;
        }

        public bool Delete(NoticeType type)
        {
            using (Models.BarContainer container = new BarContainer())
            {
                container.NoticeTypeSet.DeleteObject(type);
                if (container.SaveChanges() > 0)
                {
                    return true;
                }
            }
            return false;
        }

        public NoticeType Find(Guid id)
        {
            using (Models.BarContainer container = new BarContainer())
            {
                return container.NoticeTypeSet.Where(p => p.Id == id).FirstOrDefault<NoticeType>();
            }
        }

        public List<NoticeType> FindAll()
        {
            using (Models.BarContainer container = new BarContainer())
            {
                return container.NoticeTypeSet.ToList<NoticeType>();
            }
        }
    }
}
